<?php
include("const_sql.php");
include("settings.php");
include("classes" . DIRSEP . "connection.php");
include("classes" . DIRSEP . "router.php");

function general_init($registry){
	global $settings;
	global $sql;
	
	$registry['db'] = new DBConnect(
		$settings['db_server'],
		$settings['db_login'],
		$settings['db_password'],
		$settings['db_name']);
		
	if ($registry['db']->hasError())
		setError($registry, $registry['db']->getError());
		
	$registry['db']->clearError();		
	$registry['db']->setQuery($sql['SETNAMES'], $settings['db_names']);
	
	if ($registry['db']->hasError())
		setError($registry, $registry['db']->getError());
		
	$registry['pagination'] 	= $settings['pagination'];
	$registry['rows_per_page'] 	= $settings['rows_per_page'];
	$registry['router']			= new Router($registry);
}

function setError($registry, $errorstr)
{
	$registry['errorstr'] .= "<br />" . $errorstr;
}

function _404() {
	header("HTTP/1.0 404 Not Found");
	include("404.html");
}
?>